import {baseFilePath} from "@/until/publicConfig";

const baseMixins = {
  data() {
    const {
      windowHeight
    } = uni.getSystemInfoSync()
    return {
      windowHeight,
      fullStyle: `height:${windowHeight}px;width:750rpx`,
      contentStyle: 'height: calc(100% - 300rpx);',
      loading: false,
      baseFilePath
    }
  },
  watch: {
    loading(val) {
      val ? this.showLoading() : this.hideLoading();
    }
  },
  methods: {
    goSubPage(url) {
      uni.navigateTo({url});
    },
    showLoading(title = '加载中') {
      uni.showLoading({title});
    },
    hideLoading() {
      uni.hideLoading();
    },
     getParams(url) {
        const regex = /[?&]([^=#]+)=([^&#]*)/g;
       const params = {};
       let match;
       while (match = regex.exec(url)) {
         params[decodeURIComponent(match[1])] = decodeURIComponent(match[2]);
       }
       return params;
    }
  },
}

export {baseMixins}
